<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head> 
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
      <script type="text/javascript">
        var datagrid;
        var message =$.messager;
        var operateDialog;
        $(function() {
            datagrid=$('#datagrid').datagrid({
                url : '${path}/business/supplier_quality/audit/ajaxAllList.do',
                queryParams:imonJYRH.serializeObject($("#tableForm *")),
                onLoadSuccess:function(){
                    datagrid.datagrid('clearSelections');
                }
            });
        });
        //子页面返回方法
        function returnResult(){
            operateDialog.dialog('close');
            datagrid.datagrid('unselectAll');
            datagrid.datagrid('reload');
            parent.search_();
        }
        //判断选择单据是否是一条
        function isChooseOne(rows){
            var flag = false;
            if(rows.length >1 ) {
                message.show({
                    msg : "<spring:message code='msg.choose' arguments='"+rows.length+"'/>",
                    title : '<spring:message code='msg.tip'/>'
                });
                flag = false;
            } else if (rows.length == 0) {
                message.show({
                    msg : "<spring:message code='msg.please.choose'/>",
                    title : '<spring:message code='msg.tip'/>'
                });
                flag = false;
            }else{
                flag = true;
            }
            return flag;
        }
   
         function modify_(){
            var rows = datagrid.datagrid("getSelections");
            if(!isChooseOne(rows)){return;}
            var href = '${path}/business/supplier_quality/audit/modifyUI.do?id='+rows[0]['id'];
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.modify'/>',
                width:900,height:356
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
        
          function add_() {
          var id=$("#supplierId").val();
            var href = '${path}/business/supplier_quality/audit/processaddUI.do?id='+id;
            operateDialog = $("#operateDialog").dialog({
                title : '<spring:message code='msg.create'/>',
                width:900,height:356
            });
            $("#operateIFrame")[0].src=href;
            operateDialog.dialog('open');
        }
        
          function delete_(){ 
              
            var ids = getSelectedIds();
            $.messager.confirm(
                    '<spring:message code='msg'/>',
                    '<spring:message code='msg.confirm.delete'/>',
                    function(r){
                        if (r && null!=ids){
                            imonJYRH.showZone();
                            $.ajax({
                                url : imonJYRH.url("${path}/business/supplier_quality/audit/ajaxDelete.do"),
                                cache : false,
                                data :{'ids':ids.join(',')},
                                success : function(reMsg) {
                                    if(reMsg.success){
                                        search_();
                                        parent.search_();
                                        message.show({
                                            msg : reMsg.msg,
                                            title : '<spring:message code='msg.tip'/>',
                                            showType:'slide'
                                        });
                                    }else{
                                        message.alert('<spring:message code='msg.tip'/>',reMsg.msg);
                                    }
                                    imonJYRH.hideZone();
                                }
                            });
                        }
                    });
          
         }
          function getSelectedIds(){
            var rows = datagrid.datagrid("getSelections");
            if (rows.length > 0) {
                var ids = [];
                for ( var i = 0; i < rows.length; i++) {
                    ids.push(rows[i].id);
                }
                return ids;
            }else{
                $.messager.alert('<spring:message code='msg.error'/>','<spring:message code='msg.delete'/>','error');
                return null;
            }
        }
          function search_() {
            datagrid.datagrid('unselectAll');
            datagrid.datagrid('load', imonJYRH.serializeObject($("#tableForm *")));
        }
    </script>
</head>
<body class="easyui-layout">
<div data-options="region:'north'" style="overflow: hidden;">
    <div class="datagrid-toolbar" style="height: auto;">
        <br/>
        <fieldset>
            <table width="100%" id="tableForm">
                  <tr>
                    <td align="right">SupplierCode供应商编码：</td>
                    <td>
                        <input type="hidden" id="supplierId" name="supplierId" value="${vo.id}"/>
                        <input type="text" id="supplierId" disabled name="supplierCode" value="${vo.code}"/>
                    </td>
                    <td align="right">SupplierName供应商名称：</td>
                    <td>
                        <input type="text" disabled name="supplierName" id="supplierName" value="${vo.name}"/>
                    </td>
                </tr>
            </table>
        </fieldset>
        <br/>
    </div>
</div>
<div data-options="region:'center'">
    <div id="tb">
        <!--<a class="font-stress easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-save" title="记得保存哦，不然操作过的数据丢失！">Save保存</a>-->
        <a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-add" onclick="add_();"><spring:message code="bar.command.add"/></a>
        <a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-edit" onclick="modify_();"><spring:message code="bar.command.modify"/></a>
        <a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-cancel" onclick="delete_();"><spring:message code="bar.command.delete"/></a>
        <!--<a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-import">Import导入</a>-->
        <!--<a class="easyui-linkbutton" href="javascript:void(0);" plain="true" iconCls="icon-export">Export导出</a>-->
    </div>
    <table  toolbar="#tb" pagination="true" fit="true" nowrap="false" id="datagrid">
        <thead>
        <tr>
            <th field="ck" checkbox="true"></th>
             <th field="supplierCode" width="80" align="center">SupplierCode<br/>供应商编码</th>
            <th field="supplierName" width="100" align="center">SupplierName<br/>供应商名称</th>
            <th field="code" width="80" align="center">AuditCode<br/>审核编码</th>
            <th field="planificationDates" width="120" align="center">PlanificationDate<br/>计划日期</th>
            <th field="certificationDates" width="120" align="center">CertificationDate<br/>审核日期</th>
            <th field="value" width="100" align="center">EvaluationValue<br/>估值</th>
            <th field="project" width="80" align="center">Project<br/>项目</th>
            <th field="auditor" width="80" align="center">Auditor<br/>审核者</th>
            <th field="requestActionDates" width="130" align="center">RequestedActionsDate<br/>要求行动的日期</th>
            <th field="actionIncomingDates" width="120" align="center">ActionIncomingDate<br/>行动来临的日期</th>
            <th field="agreedActionDates" width="120" align="center">AgreedActionDate<br/>同意行动的日期</th>
            <th field="capability" width="100" align="center">Capability<br/>产能</th>
            <th field="states" width="100" align="center">Status<br/>状态</th>
        </tr>
        </thead>
    </table>
</div>
<div id="operateDialog" class="easyui-dialog" style="width:900px;height:320px;"
     data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">
    <iframe scrolling="auto" id='operateIFrame' frameborder="0"  src="" style="width:100%;height:100%;"/>
</div>
</body>
</html>
